package SortStringFromFile;

import java.io.*;

public class SortStringFromFile {
    public static void main(String[] args)
    {
        String inputFilePath = "src/main/s.txt";
        String outputFilePath = "src/main/ss.txt";

        try(BufferedReader reader = new BufferedReader(new FileReader(inputFilePath));
            BufferedWriter writer = new BufferedWriter(new FileWriter(outputFilePath)))
        {
            String line = reader.readLine();
            if(line!=null)
            {
                //将字符串转换为字符数组并排序
                char[] chars = line.toCharArray();
                java.util.Arrays.sort(chars);

                //将排序后的字符数组转换回字符串
                String sortedLine = new String(chars);

                //将排序后的字符串写入输出文件
                writer.write(sortedLine);
            }
        }catch(IOException e)
        {
            e.printStackTrace();
        }
    }
}
